package cn.white.ymc.mvvmmaster.data.api;

import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Retrofit 请求工具类
 *
 * @packageName: cn.white.ymc.mvvmdemo.data.util
 * @fileName: RetrofitFactory
 * @date: 2018/11/5  16:37
 * @author: ymc
 * @QQ:745612618
 */

public class RetrofitFactory {

    private static OkHttpClient client;
    private static Retrofit retrofit;

    private static final String HOST = "https://api.github.com";

    static {
        client = new OkHttpClient.Builder()
                .connectTimeout(10, TimeUnit.SECONDS)
                .build();

        retrofit = new Retrofit.Builder()
                .baseUrl(HOST)
                .client(client)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
    }

    public static Retrofit getInstance() {
        return retrofit;
    }

}
